{extend name="layout" /}

{block name="title"}
<title>设置分页 - thinkPHP极速后台开发</title>
<meta name="title" content="设置分页 - thinkPHP极速后台开发">
<meta name="keywords" content="设置分页,php,后台开发包，thinkphp、easyadmin、admin,easy,thinkeasyadmin">
<meta name="description" content="设置分页,快速设置列表页面的分页查询;easyadmin灵活可定制的thinkphp的后台开发工具包,助你快速开发后台">
{/block}

{block name="main"}

<fieldset id="page" class="layui-elem-field">
    <legend>分页</legend>
    <div class="layui-field-box">
        <p>分页的相关配置,只需要重写<code>configListPagination</code>方法</p>
        <pre class="php">
#project\app\admin\controller\Category.php

namespace app\admin\controller;

use easyadmin\app\libs\Pagination;

class Category extends \easyadmin\controller\Admin
{

    protected function configListPagination(Pagination $pagination)
    {

    }

}

</pre>
        <fieldset class="layui-elem-field layui-field-title">
            <legend>设置每页查询多少条数据</legend>
            <div class="layui-field-box">
                        <pre class="php">
#project\app\admin\controller\Category.php

protected function configListPagination(Pagination $pagination)
{
    $pagination->setPageSize(1);
}
</pre>
            </div>
        </fieldset>
        <fieldset class="layui-elem-field layui-field-title">
            <legend>设置分页的额外参数,分页按钮上增加参数</legend>
            <div class="layui-field-box">
                        <pre class="php">
#project\app\admin\controller\Category.php

protected function configListPagination(Pagination $pagination)
{
    $pagination->setOptions([
        'name'=>'php'
    ]);
}
</pre>
            </div>
        </fieldset>
        <fieldset id="page-template" class="layui-elem-field layui-field-title">
            <legend>自定义分页渲染模板 - 使用模板继承</legend>
            <div class="layui-field-box">
                       <pre class="php">

#project\app\admin\views\list\page.html

{extend name="@list:page" /}

{block name="main"}
    {literal}{__block__}{/literal}
    #您的自定义内容,或者去掉{literal}{__block__}{/literal},完全重写样式
{/block}
</pre>
                <p>这里运用了 thinkphp 的模板继承</p>
                <p><code>{extend name="@list:page" /}</code>表示继承原来的 分页模板</p>
                <p><code>{literal}{__block__}{/literal}</code> 表示调用原来的主体内容,是 <a target="_blank" href="https://www.kancloud.cn/manual/think-template/1286403">thinkphp-template</a> 的用法</p>
                <br><br>
            </div>
        </fieldset>
        <fieldset class="layui-elem-field layui-field-title">
            <legend>指定模板路径</legend>
            <div class="layui-field-box">
                  <pre class="php">
#project\app\admin\controller\Category.php

protected function configListPagination(Pagination $pagination)
{

    $pagination->setTemplate('page');
    //$pagination->setTemplate('list:page');//同 thinkphp-template 用法相同
}
</pre>
                <p>会查找<code>project\app\admin\views\page.html</code> 进行渲染, 模板内容同上面的<a href="#page-template">模板继承</a></p>
            </div>
        </fieldset>


    </div>
</fieldset>

{/block}


